﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DddCms.Domain.Utility;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.Unity;

namespace DddCms.Infrastructure.Logging
{
    /// <summary>
    /// Use for Logging Application Block
    /// </summary>
    public class LoggingUtil : ILoggingUtil
    {
        /// <summary>
        /// Logging Application Block Class
        /// </summary>
        [Dependency]
        public LogWriter LogWriter { get; set; }

        /// <summary>
        /// Print log in listener.
        /// </summary>
        /// <param name="categorie">categorie of log</param>
        /// <param name="title"> log title</param>
        /// <param name="message">log message</param>
        public void Verbose(string categorie, string title, string message)
        {
            LogEntry logEntry = new LogEntry();
            logEntry.Severity = System.Diagnostics.TraceEventType.Verbose;
            logEntry.Message = "**" + title + "**" + " " + message;
            logEntry.Categories.Add(categorie);
            LogWriter.Write(logEntry);
        }

        /// <summary>
        /// Print log in listener.
        /// </summary>
        /// <param name="categorie">categorie of log</param>
        /// <param name="title"> log title</param>
        /// <param name="message">log message</param>
        public void Information(string categorie, string title, string message)
        {
            LogEntry logEntry = new LogEntry();
            logEntry.Severity = System.Diagnostics.TraceEventType.Information;
            logEntry.Message = "**" + title + "**" + " " + message;
            logEntry.Categories.Add(categorie);
            LogWriter.Write(logEntry);
        }
    }
}
